package short_semester.questionnaire_planet.response.AnalyseController;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import short_semester.questionnaire_planet.pojo.*;

import java.util.LinkedList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class QuestionAlnalyseResponse {
    private Integer questionId;

    private String title;

    private String type;

    private Integer questionAmount = 0;

    private List<OptionAnalyseResponse> options = new LinkedList<>();

    public QuestionAlnalyseResponse(SingleChoiceQuestion question) {
        questionId = question.getId();
        title = question.getTitle();
        type = question.getType();
        questionAmount = question.getCount();
        for (SingleChoiceOption option: question.getOptions()){
            options.add(new OptionAnalyseResponse(option));
        }
    }

    public QuestionAlnalyseResponse(MultiChoiceQuestion question) {
        questionId = question.getId();
        title = question.getTitle();
        type = question.getType();
        questionAmount = question.getCount();

        for (MultiChoiceOption option: question.getOptions()){
            options.add(new OptionAnalyseResponse(option));
        }
    }

    public QuestionAlnalyseResponse(FillBlankQuestion question) {
        questionId = question.getId();
        title = question.getTitle();
        type = question.getType();
        questionAmount = question.getCount();
    }

    public QuestionAlnalyseResponse(ScoreQuestion question) {
        questionId = question.getId();
        title = question.getTitle();
        type = question.getType();
        questionAmount = question.getCount();
        for (ScoreOption option: question.getOptions()){
            options.add(new OptionAnalyseResponse(option));
        }
    }
}